//! ```bash
//! cargo run --example lexer_demo -- basic.sy
//! ```
use std::fs;
use compiler::lexer::tokenize;
fn main() {
    let filename = "./examples/test_lexer.sy";

    let input = fs::read_to_string(filename).unwrap_or_else(|e| {
        eprintln!("Failed to read file {}: {}", filename, e);
        std::process::exit(1);
    });

    let (tokens, errors) = tokenize(&input);
    if !errors.is_empty() {
        for e in errors {
            println!("{}", e);
        }
    } else {
        for (token, line, text) in tokens {
            println!("{} {} at Line {}.", token, text, line);
        }
    }
}